package top.infopub.enums.bpa;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public enum SureContractTypeEnum {
    SURE_CONTRACT_TYPE1("1", "设备合同"),
    SURE_CONTRACT_TYPE2("2", "分包合同"),
    SURE_CONTRACT_TYPE3("3", "对内合同"),
    SURE_CONTRACT_TYPE4("4", "其他合同"),
    SURE_CONTRACT_TYPE5("5", "对外合同");


    private String code;

    private String name;

    SureContractTypeEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static SureContractTypeEnum getByCode(String code) {
        if (StringUtils.isBlank(code)) return null;
        for (SureContractTypeEnum sct : SureContractTypeEnum.values()) {
            if (StringUtils.equals(code, sct.getCode())) {
                return sct;
            }
        }
        return null;
    }

    public static List<Map<String, String>> asList() {
        List<Map<String, String>> list = new ArrayList<>();
        Map<String, String> map;
        for (SureContractTypeEnum yone : SureContractTypeEnum.values()) {
            map = new HashMap<>();
            map.put("code", yone.getCode());
            map.put("name", yone.getName());
            list.add(map);
        }
        return list;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
